import unittest
import requests
import app
class login(unittest.TestCase):

    def test01_login(self):
        login_url = app.BASE_URL + "/api/sys/login"
        login_data = {
            "mobile": "13800000002",
            "password": "123456",
        }
        response = requests.post(url=login_url, json=login_data)
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertEqual(10000, response.json().get("code"))
        self.assertEqual(True, response.json().get("success"))
        self.assertIn("操作成功", response.json().get("message"))

        # 提取token信息
        app.TOKEN = "Bearer " + response.json().get("data")
        app.Headers_data["Authorization"] = app.TOKEN


